
	var itemDict={}
	units={}
	myGet("pda/getUnits",  function(res) { 
		for(var i=0;i<res.length;i++){ 
			var u=res[i] 
			units[u.value]=u.label
		} 	
	} );
	myGet("item/findAll",   function(res) { 
		var  items= res;
		for(var i=0;i<items.length;i++){ 
			var item=items[i] 
			item.all=item.c+ item.n+item.g;
			itemDict[items[i].i]=item;
		} 	
	} );

	function getItem(id){
		var item=itemDict[id];
		var v =  item.all;
		return v; 
	}
	function getItems(v,count){
		var items=[];
		for(var k in itemDict){
			if(itemDict[k].all.indexOf(v)>=0){

				items.push(itemDict[k]);
				if(items.length>=count){
					return items; 
				}
			} 
		} 
		return items; 
	}
		 
	function myGet(url,fun){
		mui.get(url, "", function(res) { 
			if (res.code != "200") {
				mui.confirm(res.msg)
				return;
			} 
			fun(res.data) 
		}, "json");
	}

	function myPost(url,data,fun){
		mui.post(url,data, function(response) { 
			 if (response.code != "200") {
				 mui.confirm(response.msg)
				 retun;
			 } 
			 fun(response.data); 
		 }, "json");
	}


	function confirmEvent(title,fun){
		var btnArray = ['确认', '取消'];
		return function(event) {
			var elem = this;
			mui.confirm(title, '提示', btnArray, function(e) {
				if (e.index == 0) {
					fun(elem)
				} else {
					setTimeout(function() {
						mui.swipeoutClose(elem);
					}, 0);
				}
			});
		}


	}
			
	